home *** CD-ROM | disk | FTP | other *** search
- "view.self,v 1.8 1993/07/22 00:15:49 richards Exp"
- "views - a simple X interface and widget set for Self"
-
- "This is it - the VIEW object"
-
- "views
- display a model
- use a viewManager for the workstation display
- are contained within a superView (window that is the parent)
- currently nil for a topView.
- "
-
- "remember lots of things like destroy, map, etc are just requests
- and lots of things, like resize calculations are better done on the
- arrival of events than the sending of the request"
-
- traits views _AddSlotsIfAbsent: (| ^ view = () |)
- traits views view _Define: (|
-
- parent*** = traits abstractView.
- identity** = mixins identity.
- eventMixin**** = viewManager eventMixin.
-
- "Opening (realising) a view does not create a copy.
- Also, once a view has been closed, it can be happily
- reopened if necessary. Remember open != show, close != hide
- (in X terms realise != map, unrealise != unmap)"
-
- ^ copyMapped = (copyRealised map).
- ^ copyMapped: vmgr = ((copyRealised: vmgr) map).
- ^ copyRealised = (copy realise).
- ^ copyRealised: vmgr = (copy realise: vmgr).
-
- "should only be called indirectly (see above)
- but this is the place to override copy"
-
- "this code must be kept in step with the unrealise code"
-
- "_" copyUnrealised: sv = (|c|
- c: resend.copyUnrealised: sv.
-
- "the following are deleted"
- c window: window deadCopy.
- c manager: nil.
- c display: nil.
-
- "the following flags reset"
- c iMapped: false.
-
- c
- ).
-
-
-
- opening* = (|
- ^ open = (realise).
- ^ open: name = (realise).
- ^ open: name Manager: vmgr = (realise: vmgr).
-
- ^ realise = (
- isTopView
- ifTrue: [realise: viewManager someManager]
- False: [realise: superView manager].
- ).
-
- ^ realise: vmgr = (|new|
-
- "override to check the subView structure, if nec"
- "the view should now be sane..."
-
- isTopView
- ifTrue: ["setup topView Behaviour"]
- False: ["setup normalView behaviour" "check superView"
- (superView isRealised)
- ifFalse: [error: 'need a realised superView to realise'].
- (superView manager == vmgr)
- ifFalse: [error: 'need the same manager as my superView'].
- ].
-
- vmgr isOpen
- ifFalse: [error: 'I need an open manager to realise upon'].
-
- "I'm not sure what this should do.."
- isRealised
- ifTrue: [warning: 'I can only realise myself _once_'. ^self].
-
- "here we go"
-
- new: xlib window
- createDisplay: vmgr display SubWindow:
- (superView isNil ifTrue: [vmgr display screen rootWindow]
- False: [superView window])
- X: x Y: y Width: width Height: height
- BorderWidth: borderWidth
- Border: (vmgr pixel: borderColour)
- Background: (vmgr pixel: background).
-
- new isNull ifTrue: [^error: 'couldn\'t create window'].
-
- "done it, so register with manager"
-
- "should be the _only_ assignment to window, display, manager"
- window: new.
-
- "configure the view"
- vmgr manage: self For: window.
- manager: vmgr.
- display: vmgr display.
-
- "configure the window"
- name: name.
- iconName: iconName.
- icon: icon.
- window eventMask: iEventMask.
- window selectInput.
-
- self).
-
- ^ isRealised = (window isLive).
- ^ isReal = (isRealised).
-
- "if theres too much of this, try dynamic inheritance"
- "WARNING: THIS RETURNS SELF"
- _ ifRealised: b = (ifRealised: b Else:
- [debugMessage: 'view: ', iName, ' is currently unrealised']).
- _ ifRealised: b Else: e = (isRealised ifTrue: b False: e. self).
- |).
-
-
- closing* = (|
-
- "this code must be kept in step with the copyUnrealised code"
- "the meanings of the variables are documted there"
-
- "we nuke the window, then catch destroy notify!"
- "subWindows will get taken out by X"
-
- ^ close = (unrealise).
- ^ destroy = (unrealise).
-
- ^ unrealise = (ifRealised: [window destroy. basicUnrealise]).
-
- "this should be called to unrealise a view"
- "after it's window _(or superView's window) has been destroyed"
- ^ basicUnrealise = (ifRealised: [
-
- manager release: self For: window.
-
- manager: nil.
- display: nil.
- window: window deadCopy.
-
- iMapped: false.
-
- ]).
-
- |).
-
- showing* = (|
- ^ show = (map).
- ^ hide = (unmap).
- ^ mapped = (iMapped).
- ^ map = (ifRealised: [window map]. iMapped: true.).
- ^ unmap = (ifRealised: [window unmap]. iMapped: true.).
- |).
-
- eventMasking* = (|
- ^ eventMask = (iEventMask).
- ^ eventMaskAdd: m = (eventMask: iEventMask || m).
- ^ eventMaskRemove: m = (eventMask: iEventMask && (m complement)).
- ^ eventMask: m = (iEventMask: m.
- ifRealised: [window eventMask: m. window selectInput]).
- |).
-
- xEvents* = (|
- mapNotify: event = (iMapped: true).
- unmapNotify: event = (iMapped: false).
-
- ^ buttonPress: event = (
- (event button == 1) ifTrue: [selectDown: event x @ event y].
- (event button == 2) ifTrue: [copyDown: event x @ event y].
- (event button == 3) ifTrue: [menuDown: event x @ event y].
- self
- ).
-
- ^ buttonRelease: event = (
- (event button == 1) ifTrue: [selectUp: event x @ event y].
- (event button == 2) ifTrue: [copyUp: event x @ event y].
- (event button == 3) ifTrue: [menuUp: event x @ event y].
- self
- ).
- |).
-
- viewEvents* = (|
- ^ selectDown: pt = (42).
- ^ selectUp: pt = (42).
-
- ^ copyDown: pt = (42).
- ^ copyUp: pt = (42).
-
- ^ menuDown: pt = (42).
- ^ menuUp: pt = (42).
- |).
-
-
- gunk* = (|
- ^ flush = (ifRealised: [display flush]).
- |).
-
- printing* = (|
- printString = ('heavyView: ',iName).
- |).
-
- drawing* = (|
- clear = (window clear).
- drawAt: p String: s = (
- window drawString: s At: p GC: manager gc
- ).
- drawAt: p String: s InFont: fontStruct = ( | lgc. |
- lgc: manager gcForFont: fontStruct fid.
- window drawString: s At: p GC: lgc.
- ).
- drawFrom: o To: c Width: w = (| lgc. |
- lgc: manager gcWidth: w.
- window drawLine: o To: c GC: lgc
- ).
- drawFrom: o To: c = (| lgc. |
- lgc: manager gcWidth: 1.
- window drawLine: o To: c GC: lgc
- ).
- drawLine: r = (
- drawFrom: r origin To: r corner + 1
- ).
- drawFrom: o For: c = (
- drawFrom: o To: o + c
- ).
- drawXorRectangleFrom: o To: c = (| lgc. |
- lgc: manager gcFunction: xlib graphicsContext gxXor.
- window fillRectangleFrom: o To: c GC: lgc.
- ).
- drawXorRectangle: rect = (| lgc. |
- lgc: manager gcFunction: xlib graphicsContext gxXor.
- window drawRectangle: rect GC: lgc.
- ).
- fillRectangle: rect = (
- window drawRectangle: rect GC: manager gc.
- ).
- clearRectangle: rect = (| lgc. |
- lgc: manager gcFunction: xlib graphicsContext gxClear.
- window drawRectangle: rect GC: lgc.
- ).
- |).
-
- fonts* = (|
- drawAt: p String: s InFontNamed: fname = (
- debugMsg: ('Asked to print: ',s,' at: ',p printString).
- drawAt: p String: s InFont: (manager openFontNamed: fname).
- ).
- drawInFixedFontAt: p String: s = (
- drawAt: p String: s InFontNamed: 'fixed'.
- ).
-
- openFontNamed: fname = (
- manager openFontNamed: fname
- ).
-
- textAscent: string = ( | fs. |
- fs: openFontNamed: 'fixed'.
- fs ascent
- ).
-
- textHeight: string = ( | fs. |
- fs: openFontNamed: 'fixed'.
- fs ascent + fs descent
- ).
-
- textWidth: string = ( | fs. |
- fs: openFontNamed: 'fixed'.
- fs xTextWidth: string
- ).
-
- ^ debugMsg: msg = (
- debugFlag ifTrue: [
- msg printLine.
- ].
- ).
- |).
-
- heavySuperView = ( self ).
- isHeavy = ( true ).
- isLight = ( false ).
- |)
-
- prototypes views _AddSlotsIfAbsent: (| ^ view = () |)
-
- prototypes views view _Define: prototypes views abstractView "get super vars "
- prototypes views view _AddSlots: (|
- parent* = traits view.
-
- ^_ window <- xlib window. "I can't make up my mind about this"
- ^_ manager <- nil.
- ^_ display <- nil.
-
- _ iMapped <- false.
-
- _ iEventMask <- xlib events exposureMask ||
- xlib events structureNotifyMask.
-
- _ iBorderWidth <- 1.
- _ iBorderColour <- 'black'.
- _ iBackground <- 'white'.
-
- |)
-